Skip to content

feat(plugin-auth): remove a pending person and retry every environment-user host call from a durable outbox - #34162

Merged
objectstack-fleet[bot] merged 15 commits into
mainfrom
claude/project-thread-32vsaq
Nov 16, 2026
Merged

objectstack-fleet[bot] merged 15 commits into
mainfrom
claude/project-thread-32vsaq

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

repo:cloud#5 · hotlong · session_01Q4EjjPP1zuWBNq3nBXVei9

Fixes #33228

Clause-②: yes (widening) — added: POST /api/v1/auth/admin/remove-sso-user (platform administrators, cloud-managed environments only); an optional userRemoved member on EnvironmentUserHost and the 'removed' value of EnvironmentUserEventKind; the 'deactivated' value of the host outcome's reason. Nothing that was accepted is refused.
Metadata-protocol: none

维护者速读

  • 改了什么: 云托管环境新增「删除待登录人员」接口 POST /admin/remove-sso-user:邮箱输错、从未登录的人可以直接删掉,同时通知云端取消其邀请;已停用的待登录人员被重新添加时不再给他发邀请。
  • 为什么改: 此前输错邮箱的待登录人员只能停用、删不掉。按裁决 A,本 PR 只保留删除接口和宿主接缝;邀请的可靠投递、重试和每人邀请状态由云端宿主自己负责,框架不再另建发件箱,避免两层各自重试、两张状态表互相矛盾。
  • 风险与回滚: 只在 OS_CLOUD_MANAGED=1 时生效,只能删「待登录」的人;新接口和宿主可选成员都是加法,没有新表、没有迁移。云端暂时连不上时删除会被拒绝(503,人员保留,稍后重试即可),不会出现「本地删了、云端邀请还在」的情况。回滚即 revert 本 PR。唯一的行为变化是停用中的待登录人员被重新添加时不再通知云端(答复里写明 deactivated)。
  • 先看: packages/plugins/plugin-auth/src/pending-sso-users.ts 的 runRemoveSsoUser / takeBackPerson(删除行时带「待登录」条件)/ removalNotDone(删除失败后的内联重新邀请),以及同文件 addOnePendingPerson 里停用判断那几行;其次 environment-user-host.ts 的 hostMember 回退。
  • 两分钟验证: pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/pending-sso-users.test.ts,预期 74 个测试全部通过。
  • 需要你做的: 无,席位落地(本 PR 767 行,低于 3000 行人合门槛,不触治理面)。

What changes

Reshaped to ruling A on the card: the remove door and the host seam stay, and the framework keeps no outbox. Delivering a host call durably, and keeping each person's invitation status, is the host's job.

Remove door. POST /api/v1/auth/admin/remove-sso-user with { "userId": "…" }, gated for platform administrators exactly as add-sso-user is.

  • Off a cloud-managed environment it answers 409 and removes no one.
  • A person who is not pending answers 409 (deactivate them instead). This also holds at the removal itself. The person is re-checked inside the unit of work, and the sys_user delete carries source: 'idp_pending' in its where (a predicate delete, which honours deleteBehavior like the by-id one). A delete that removes no row throws inside the unit of work, so the child deletes roll back. A person whose first sign-in lands while the host is asked is kept with 409, and the answer says the host was already told.
  • One window stays open (objectstack#34373, an engine defect, no workaround here). sys_user has cascading lookups. For such an object the engine reads the matching ids, walks the cascade, and then deletes { id: { $in } } with no source predicate and no row lock. A first sign-in that commits between that read and that delete is still deleted and answered 200. The docblocks, ledger note, docs and changeset all say so.
  • An unknown id answers 404. A body with any key other than userId answers 400.
  • The host is asked first, outside any transaction. Then the person's positions, permission sets, membership and row are removed in one unit of work, as the system.
  • The host is told through userRemoved. A host without that member is told through userDeactivated with source: 'idp_pending', which by ruling already means "cancel the invitation".
  • A typed host refusal (403/409) answers with the host's own sentence, and no one is removed.
  • A host that cannot be reached refuses the removal, as it refuses a deactivation. The answer is 503 SERVICE_UNAVAILABLE ("could not be reached … so they were not removed. Nothing was changed; try again."); the person is kept and no invitation is re-sent. The door calls the host once and keeps no record to ask again from, so removing the person would leave an invitation nothing could cancel.
  • With no host wired, the person is removed and the answer says host: { notified: false, reason: 'no_host' }.
  • A person other records still point at (deleteBehavior: 'restrict') answers the engine's refusal, and no one is removed. When the host had already taken the cancellation and the person is still pending and not deactivated, the door sends the invitation again inline, once, through userAdded. The answer says whether that worked ("it was sent again", or "sending it again did not succeed, so they stay pending with no invitation: add them again"). Nothing is retried later.

A deactivated person is never sent an invitation (review#1 S1, the in-door half). Re-adding a pending person who is deactivated no longer calls userAdded. The answer is 200 alreadyPending with host: { notified: false, reason: 'deactivated' }. Reactivating them (admin/unban-user) is what tells the host again. A banned column read back as true, 1, '1' or 'true' counts as deactivated.

Host contract. EnvironmentUserHost gains an optional userRemoved(event), and EnvironmentUserEventKind gains 'removed'. The seam's header now says each door calls the host once, and that a host which must not lose a call queues and retries it on its side.

Also.

  • Auth route ledger row for the new door, plus the ledger-hygiene pin.
  • Both dogfood admin sweeps classify it (admin-platform-admin-standing, admin-route-nonadmin-refusal).
  • content/docs/permissions/authentication.mdx documents the door, the deactivated re-add, and what is the host's job (durable delivery, per-person status, treating a repeat as harmless, cancelling by userId, never by email address).

Dropped from the earlier head 3c25103f (ruling A):

  • sys_environment_user_outbox (object, platform-objects export, platform-object-names.ts row, cli ownership inventory row, tenancy census rows and census-page figures, the 21 generated translation files);
  • environment-user-outbox.ts (worker, lease, backoff, boot, accepted trigger) and its tests;
  • every outbox write in add, import, ban, unban and remove;
  • deliveryId on EnvironmentUserEvent;
  • the invitation: { id, status } answer fields;
  • the opts.retried argument of notifyEnvironmentUserHost;
  • the cli, spec and platform-objects changesets.

Outside the files listed below, the tree is byte-identical to main. admin-ban-endpoints.ts and manifest.ts are back to main too.

Tests

pending-sso-users.test.ts (+16 tests, 74 in the file):

  • Remove door:
    • removes the row, grants and membership, and tells userRemoved first;
    • the userDeactivated fallback for a host without userRemoved;
    • a not-pending person gets 409, no host is called, and no one is removed;
    • a typed host refusal leaves the person in place;
    • an unreachable host refuses the removal with 503: the person is kept, the host is asked once, and nothing is re-sent;
    • no_host;
    • the restrict refusal re-invites inline through userAdded;
    • a re-invite the host does not take is answered truthfully;
    • 404, 400 (missing id, unknown key) and 403 (non-admin);
    • the not-managed 409.
  • S1 and pending at the write:
    • re-adding a deactivated pending person calls no userAdded and answers deactivated;
    • CONTROL: re-adding an active pending person invites again;
    • a refused removal of a deactivated pending person sends no new invitation;
    • a banned column read back as '1' or 'true' is deactivated on a re-add;
    • a person who signs in while the host is asked is kept with 409;
    • a person whose first sign-in lands inside the unit of work, after the pending read and before the row's delete, is kept with 409, and their positions, permission sets and membership survive. The memory engine has no transaction, so the test gives it a snapshot transaction, which the plugin's runAtomically seam calls. The test asserts that the removal entered that seam once and that the child rows were restored when NoLongerPending was thrown. This proves the door's rollback path against the seam; on the real engine the window above still applies.

Also: auth route ledger conformance, and the two dogfood admin sweeps.

Acceptance notes

Verification

At head 2e868fa7e24 (origin/main 8436f67a2 merged at 1f1f43cbb), heavy runs under the shared verify lock.

  • PR size against main: 11 files, +733 / −34 = 767 changed lines, nothing generated. This is under the 3000-line human-merge threshold, and no governed surface is touched.
Gates
  • Full derived run at 1f9b39d2606 (the previous head): dispatch-gates --commands --repo objectstack-ai/objectstack derived 108 families. Each ran with stdin from /dev/null and its exit code was captured before any pipe. 106 exited 0. check:skill-examples exited 3 (client-react not built), then 0 after a client-react build. check:dual-build-cjs-loads exited 3 (needs a repo-wide build) and was NOT MEASURED locally; Lint & Repo Gates ran it in CI and succeeded. --ran with :: exit codes: "108 derived famil(ies) accounted for — 107 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)".
  • This round at 2e868fa7e24 changed only prose (a docblock, the ledger note, the docs paragraph and the changeset) and one test. Re-run locally: the gate subset that reads those files, 14 of 14 exit 0. They are check:doc-authoring, check:auth-mount-ledger, check-affected-docs, check-drift-comment, check-empty-changeset, check-changeset-no-major, check:nul-bytes, check:issue-citations (both forms), check:docs-transcript-drift, check:doc-anchors, check:cross-package-test-inputs, check:engine-double-contract and check:closed-ceremony-text. The full family set is declared to CI for this head.
  • PR check-runs on 2e868fa7e24 at write time: 33 success, 15 skipped, 4 in progress, none failed. Lint & Repo Gates, TypeScript Type Check, Build Core, Check Changeset and Governed Surface Queue Guard are success; Test Core was in progress.
  • Not run locally, left to CI: pnpm lint, test:repo, and the dogfood battery (the title has no ! and Clause-②: has no narrowing arm).
Tests
  • pnpm --filter @objectstack/plugin-auth test: Test Files 279 passed (279), Tests 5667 passed | 10 skipped (5677).
  • pnpm --filter @objectstack/plugin-auth typecheck: exit 0.
  • pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/pending-sso-users.test.ts: 74 passed.
Ablations

Each mutation went through scripts/ablation-replace.mjs in wrap mode (the anchor hit once and the mutation landed, verified against the blob). Each went red and was restored with blob == HEAD (the last two at d2608bc280f4) and an empty git diff HEAD. The suite imports source, so no dist/ leg applies.

  • Row delete without the pending marker (where: { id, source } reduced to where: { id }): 1 failed (the in-unit sign-in case). Run at both 1f9b39d26 and 2e868fa7e.
  • takeBackPerson run without its unit of work (await (unit ? unit.runAtomically(work) : work()) reduced to await work()), at 2e868fa7e: 1 failed, the in-unit case ("the removal ran inside the transactional seam: expected +0 to be 1").
  • The unreachable-host refusal disabled: 1 failed ("a host that cannot be reached refuses the removal: 503").
  • isDeactivated without the string forms: 1 failed ("a banned column read back as a string"). The first attempt was a no-op: ablation-replace refused it because the replacement (a bare semicolon) was not distinct, and nothing ran. It was redone with a distinct replacement.
  • The in-unit pending pre-read reduced to an existence check: 1 failed ("a person who signs in while the host is asked", whose membership assertion catches the child deletes the memory engine cannot roll back).
  • The userDeactivated fallback disabled in hostMember: 1 failed.
  • The S1 guard (if (existing.deactivated) made false): 2 failed (the re-add case and the string-forms case).
  • The inline re-invite disabled: 2 failed (the restrict re-invite case and the truthful-failure case).
  • The re-invite's deactivated check dropped: 1 failed ("a refused removal of a deactivated pending person sends no new invitation").

Generated by Claude Code

@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation protocol:system tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-auth, touching 37 documentable anchor(s).

36 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12.

⛔ 13 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: sys_user (literal, 55 pages)
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 45f890bb22c1672d47f8a55159dda30ae16e94da — the merge of head 2e868fa7e24849da3062c3616ba80594c206de7d into base 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 45f890bb22c1672d47f8a55159dda30ae16e94da && git checkout 45f890bb22c1672d47f8a55159dda30ae16e94da
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12 2e868fa7e24849da3062c3616ba80594c206de7d && git checkout -B drift-repro 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12 && git merge --no-ff 2e868fa7e24849da3062c3616ba80594c206de7d

node scripts/docs-audit/affected-docs.mjs --json 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

Contract-review-claim: session_01L9qibzuZJBQY4wUQFJbkfx · head 17f7933 · 2026-11-15T22:33Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 17f7933a660b8e4b4bc74889876d54e070851b1c
Local-runs: none
Scope: packages/spec/src/system/constants/platform-object-names.ts + packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts, packages/plugins/plugin-auth/src/environment-user-host.ts, packages/plugins/plugin-auth/src/environment-user-outbox.ts, packages/plugins/plugin-auth/src/pending-sso-users.ts, packages/plugins/plugin-auth/src/admin-ban-endpoints.ts, packages/plugins/plugin-auth/src/pending-sso-marker.ts, packages/plugins/plugin-auth/src/auth-plugin.ts, packages/plugins/plugin-auth/src/manifest.ts, packages/plugins/plugin-auth/src/auth-route-ledger.ts, content/docs/permissions/authentication.mdx (the environment-user host and outbox paragraphs)

Inputs read: card #33228 (body and its four comments), the ruling text on #33181 comment 6870710213, PR #34162 (body, 46 files, net diff against main), and the check-runs on this head. The rest of the diff (tests, generated translation bundles, censuses, the cli inventory row, the changeset prose) is the lane seat's ACCEPT at TIER_DEFAULT.

Check-runs on this head when read: 28 concluded success, 10 skipped, 0 failed, 27 still running (Test Core 1/8 to 8/8, Test UI 1/16 to 16/16, Type Check · workspace, Type Check UI, Build & E2E UI). Concluded green: Check Changeset, Check PR Size, Governed Surface Queue Guard, PR-body guards, Spec property liveness, Lint · PM dispatch-gates and every other Lint family, Type Check · source gates / consumer gates / debt ledger, Build Core, Build Docs, Dogfood Regression Gate, Live E2E UI. ⛔ No test shard had concluded: this record judges the design and the concluded gates, and the test verdict is still owed by the shards.

① Derived judgments

  • New route POST /api/v1/auth/admin/remove-sso-user: a widening. Right. It has its AUTH_ROUTE_LEDGER row, both dogfood admin sweeps classify it, and it sits behind the same gateAdmin as the two add doors.
  • EnvironmentUserHost.userRemoved? and EnvironmentUserEvent.deliveryId?: optional, additive. Right. A host built before this change keeps working through the userDeactivated fallback.
  • EnvironmentUserEventKind gains 'removed': a widened exported union (index.ts re-exports environment-user-host.ts). Right as a widening; a host that switches exhaustively on the kind sees a compile error, which is the intended signal.
  • invitation: { id, status } on the add, import, ban, unban and remove answers: additive. Right. No existing answer field changes.
  • New object sys_environment_user_outbox: registered in PLATFORM_OBJECTS_BY_PACKAGE['platform-objects'] in sorted position, exported from identity/index.ts, registered by authIdentityObjects, listed in the deployment-level no-tenant test and the ADR-0131 inventory. Right.
  • Accept sets: no existing door refuses anything it accepted. ban-user keeps its 503 on an unanswered host, unban-user stays fail-open. Right: no narrowing arm is owed.
  • Engine writes: every compare-and-set write is spelled { where: { id, extra key }, multi: true }, which resolveEngineUpdateDispatch routes to driver.updateMany (the A compare-and-set where on a by-id update is silently inert — the extra predicate keys never reach the driver, and SqlHttpOutbox.redeliver's status guard is one of them #11009 compare-and-set spelling), and every write runs under isSystem, which the static read-only strip exempts. Right: the claim and the settlement are real conditional writes, and the all-readonly fields do not drop them.

② Semver level

patch on plugin-auth, platform-objects, spec and cli, with Clause-②: yes (widening) and Metadata-protocol: none in both the PR body and the changeset. This matches the diff: nothing a metadata author can write changes, and AGENTS.md gives a non-protocol widening patch. The four packages are the four the diff moves. Check Changeset concluded success. Agreed.

③ Boundary flags

  • Tier H: 3368 added lines, over 3000. Landing needs os-zhuang's approval after this record; Check PR Size and the queue guard stay whole-PR.
  • open_questions: empty in the os-dev-report (comment 6902462660). Nothing to answer.
  • Flag: out-of-surface registrations (platform-object-names.ts, the cli inventory, the two tenancy censuses): required by the conformance gates for a new platform object. Accepted.
  • Flag: no explicit admin audit row for a removal: read in the tree. The delete runs under authSystemWriteContext() inside runAttributedToUser, so it carries the administrator as attributedUserId. Accepted as stated.
  • Flag: where the outbox lives (the card left host-owned versus framework object to the maintainer): the claim comment reads the ruling's "Execution terms for the environment" as environment-side, and the diff builds that. The ruling text supports it ("mirror sys_environment_revocation"). Accepted; no escalation.
  • security_findings: withheld in the report: nothing was handed to this review. See the first should-fix below, stated in rule terms.

④ Design judgment

packages/spec/src/system/constants/platform-object-names.ts (hits). One name added to the platform-objects group, which the file's own maintenance contract requires for any object a platform package registers. Its first consumer is the cross-reference check that tells a real sys_ name from a typo; the name matches the object's name and the constant in environment-user-outbox.ts. Holds.

Ruled terms, against the tree.

  • "No database transaction is held across the invite call": holds. The add door writes the person and the in_flight row in one unit and calls the host after it. Ban, unban and remove call the host before their write. The re-add and the worker call it with no unit open.
  • The per-row synchronous 403 at the developer cap: holds. The door still makes the first call, a refused add is taken back out and its row reads failed with the host's code, and an import settles each row on its own.
  • Ruling 5's owner/admin 409: holds. ban-user is unchanged (refusal answered, 503 on an unanswered host, nothing written). A refused removal removes no one and records nothing.
  • "Deleting or deactivating a pending row cancels its cloud invitation": holds on the main paths, and fails on the edge path in the first should-fix.
  • The remove door's refusals: off a managed kernel 409 before the body is read; unknown id 404; unknown key 400; a non-pending row 409 before any host call; a non-admin stops at gateAdmin. Holds, except for the timing gap in the second should-fix.
  • The fallback: hostMember picks userDeactivated only for removed and only when userRemoved is not a function; the event carries source: 'idp_pending'. Holds.
  • What the outbox stores: event_json holds the person's id, email and name, the administrator's id, their cloud user id and impersonatedBy. last_error holds a fixed sentence, or the host's own refusal sentence. No driver text and no token reaches either. Holds.
  • The boot: bootEnvironmentUserOutbox returns before touching the engine unless a host is wired and isCloudManaged() is true; destroy() stops the worker. Holds.
  • The lease: a pending row is claimed by a conditional write and a token read-back; a lapsed in_flight row is taken by its old token; a settlement writes only under the token it holds. Two workers that read the same row give one holder. Holds. Delivery is at least once, as the header says: a door call slower than the two-minute lease is sent again under the same deliveryId.

Should-fix 1 — an invitation can be sent for a person who is deactivated while pending. The invariant "a deactivated pending person holds no live invitation" is not held by the worker. stillOwed judges an added row by the pending marker alone and never reads banned, and supersedeOpenOutboxRows stops only rows in pending, so an added row in in_flight survives a deactivation. Separately, the remove door queues a fresh invitation after a failed removal without asking whether the person is deactivated, and without asking whether the host was told to cancel at all (it also queues one when the host was never reached, and the answer then says the invitation "had already been cancelled", which is false). This is the ruled term "deleting or deactivating a pending row cancels its cloud invitation" failing on an edge path. Fix: stillOwed treats a banned person as not owed an added row, and the re-send after a failed removal fires only when the host took the cancellation and the person is not deactivated.

Should-fix 2 — the remove door's "pending only" check is not held at the write. runRemoveSsoUser reads source, calls the host, then takeBackPerson deletes sys_user by id alone. A person whose first sign-in clears the marker during the host call is deleted with their grants and membership, although the door's contract is "refused for any row that is not pending". Fix: make the delete conditional on the marker (or re-read it inside the unit of work) and answer the 409 when it no longer holds.

Should-fix 3 — on a kernel with a host wired that is not cloud-managed, the ban and unban doors queue rows no worker drains. adminBanDeps passes the host wherever the option is set, and recordAsk writes whenever a host answered. The worker boots only on a cloud-managed kernel. There a reactivation the host did not take is written pending, the answer says invitation: { status: 'pending' } and the log says "The call is retried", and nothing retries it. The boot's own comment ("elsewhere no door writes a row") is false for these two doors. Fix: record only on a cloud-managed kernel, matching the boot.

Nits.

  • The accepted trigger skips in_flight rows, so a person who signs in during a send keeps a row that reads sent.
  • A pending row's claim is conditional on status alone. A worker holding a stale read can claim a row another worker has just settled back to pending, which sends it before its backoff and undercounts attempts.
  • "Every call to the host about a person is recorded" (docs, the object's jsdoc, the module header) overstates: a non-pending deactivation and a refused ban, unban or removal write no row. The changeset words it correctly.
  • The environmentUserHost option jsdoc in auth-plugin.ts still lists only add, deactivate and reactivate.
  • A queued removed call can reach the host after the same address was added again as a new person. The event names the removed userId; the docs should tell a host to cancel by userId or deliveryId, not by address.
  • The boot runs inside the kernel:ready block whose catch swallows everything, so a worker that fails to start says nothing.

Per file. sys-environment-user-outbox.object.ts: agrees with the worker (statuses, kinds, numeric next_attempt_at and claimed_until, user_id as text so the row outlives the person, get / list only, manage_platform_settings). environment-user-host.ts: agrees. environment-user-outbox.ts: agrees except should-fix 1 and the nits. pending-sso-users.ts: agrees except should-fixes 1 and 2. admin-ban-endpoints.ts: agrees except should-fix 3. pending-sso-marker.ts, manifest.ts, auth-route-ledger.ts: agree. auth-plugin.ts: agrees, with the jsdoc and boot nits. authentication.mdx: agrees with the code sentence by sentence, apart from the "every call" nit.

No must-fix. The three should-fixes earn a delta review of their fix.

Implemented-by: claude/project-thread-32vsaq
Reviewed-by: session_01L9qibzuZJBQY4wUQFJbkfx

VERDICT: PASS

…rules

No invitation is sent to a deactivated person; a removal holds to pending
people at the write; calls are recorded only on a cloud-managed kernel,
where the worker drains them. Prose says which calls are recorded.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF
…-32vsaq

# Conflicts:
#	packages/plugins/plugin-auth/src/pending-sso-users.ts
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

Contract-review-claim: session_01L9qibzuZJBQY4wUQFJbkfx · head 01d65d8 · 2026-11-15T23:59Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 01d65d851b20fb39c1f6dd14946a91806da7ee42
Local-runs: none
Scope: packages/spec/src/system/constants/platform-object-names.ts + packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts, packages/plugins/plugin-auth/src/environment-user-host.ts, packages/plugins/plugin-auth/src/environment-user-outbox.ts, packages/plugins/plugin-auth/src/pending-sso-users.ts, packages/plugins/plugin-auth/src/admin-ban-endpoints.ts, packages/plugins/plugin-auth/src/pending-sso-marker.ts, packages/plugins/plugin-auth/src/auth-plugin.ts, packages/plugins/plugin-auth/src/manifest.ts, packages/plugins/plugin-auth/src/auth-route-ledger.ts, content/docs/permissions/authentication.mdx (the environment-user host and outbox paragraphs)

Delta review of record 6902610047 for the hop 17f7933..01d65d8: the fix commit 9bb42bb, and the merge 01d65d8 of main at ea6de74. Read from the tree; the card thread's fix notes were not read.

Check-runs on this head when read: 13 concluded success, 11 skipped, 0 failed, 25 still running. Concluded green: Check Changeset, Check PR Size, Governed Surface Queue Guard, PR-body guards, Spec property liveness, Dogfood Regression Gate, Check Documentation Links. ⛔ Still running: every Lint family, every Type Check family, Build Core, Build Docs, Build UI Deps, Live E2E UI and Test Core 1/8 to 8/8. No lint, type or test verdict exists on this head yet; this record judges the design and the concluded gates, and those verdicts are still owed.

① Derived judgments

  • Accept sets and public surface: unchanged from the first record. The fix adds no route, no host member and no answer field.
  • notifyEnvironmentUserHost gains an optional fifth argument opts.retried: an exported function, additive, and it only chooses a log sentence. Right.
  • AdminBanEndpointDeps.isCloudManaged?: optional; absent reads as not managed, so nothing is recorded. Right: this is the safe default.
  • New refusal sentences (removeRefusedNotReinvited, removeHostCancelled, removeHostUnconfirmed): message text on existing 409 and engine-refusal answers. No status or code changes. Right.
  • Net diff outside the fix: unmoved. The PR still changes the same 46 files against main; for each of the 35 files the fix commit does not touch, the patch against the new base is identical to the patch against the old base.

② Semver level

Unchanged: patch on the same four packages, Clause-②: yes (widening), Metadata-protocol: none. The changeset body was reworded to match the fix and now says which calls are recorded. Check Changeset concluded success on this head. Agreed.

③ Boundary flags

  • Tier H: still over 3000 lines (3663 added against main). Landing needs os-zhuang's approval after this record.
  • open_questions: none were open, and the fix raises none.
  • The merge carries code from neither parent. git show --cc 01d65d85 shows one conflicted file, pending-sso-users.ts. The conflict itself (the logger type on PendingSsoUserDeps) is resolved correctly: it keeps this branch's wakeOutbox and takes main's wider logger type, which is a superset of what this branch used. Beyond that, the merge commit adds eight lines that exist in neither parent: userId is passed into removalNotDone, and a removal that fails with a 5xx is now logged at error (or warn) with its cause. The lines are benign and match main's new rule that a generic 500 answer logs its cause once, but they are new behaviour inside a merge commit. Flagged for the seat; not a defect in the tree.

④ Design judgment

packages/spec/src/system/constants/platform-object-names.ts (hits). Not touched in this hop. Still holds.

Should-fix 1 (an invitation for a deactivated pending person): closed.

  • stillOwed now answers superseded for an added or reactivated row whose person is deactivated, before it reads the pending marker.
  • A deactivation and a removal now supersede in_flight rows as well as pending ones. A row whose sender is still mid-call can be written back by that sender's settlement, but it then returns as pending and meets the stillOwed check, so it is not sent.
  • After a failed removal, a new invitation is queued only when the host took the cancellation and the person, re-read at that moment, is still pending and not deactivated. An unreadable person reads as deactivated, so nothing is sent.
  • When the host was never reached, nothing is queued and the answer says the cancellation was not confirmed. The false "had already been cancelled" sentence is gone.
  • Tried again: deactivate, then a refused removal; a sender that died mid-call followed by a deactivation; a deactivation landing between the re-read and the worker's send. Each ends with no invitation sent.

Should-fix 2 (pending only, held at the write): closed. The marker is re-read as the first step inside the removal's unit of work, and a person who is no longer pending is answered 409 and kept, with their grants and membership. The host call is no longer inside the gap. What remains is a check followed by a delete inside one unit, not a conditional delete; see the nits.

Should-fix 3 (rows no worker drains off a managed kernel): closed. recordAsk returns before any write unless isCloudManaged() is true, adminBanDeps passes the accessor, and the "The call is retried" log sentence is now printed only where a row is written. The boot comment matches the doors.

Nits the author reports fixed.

  • Which calls are recorded: fixed in the docs, the object's jsdoc, the module header and the changeset. They now say invitations, re-sends and cancellations on a cloud-managed environment, and that a signed-in person's deactivation is asked but not recorded.
  • The environmentUserHost option jsdoc in auth-plugin.ts: fixed. It names removal, the fallback and the outbox.
  • Cancel by userId or deliveryId, never by address: fixed in the docs and the changeset.
  • A worker that fails to start: fixed. The boot has its own try, and a failure is logged at error instead of falling into the silent catch.

New in the fix, tried against the same invariants. Nits only.

  • A person who signs in while the host is asked is kept, and the cancellation the host took is then recorded as a removed / sent row. That row is newer than their accepted row, so "the newest row is the invitation status" reads "cancelled" for a person who is active. The host was also told to cancel an invitation that had just been accepted; what it does with that is the host's contract.
  • The pending re-read and the delete are two statements in one unit of work. A sign-in that commits between them is still deleted. The gap is now a few statements, down from the length of a host call.
  • A row removed by someone else between the first read and the re-read is answered 409 "not pending", where 404 would be exact.
  • The remove door always passes retried: true, so its log says "The call is retried" even when the unit of work then fails and no row is kept. The answer to the administrator says the opposite, correctly.
  • Still open from the first record: the accepted trigger skips in_flight rows, and a pending row's claim is conditional on status alone.

Per file. environment-user-outbox.ts, pending-sso-users.ts, admin-ban-endpoints.ts, environment-user-host.ts, pending-sso-marker.ts, auth-plugin.ts, sys-environment-user-outbox.object.ts and authentication.mdx now agree with the contract sentence by sentence, apart from the nits above. manifest.ts and auth-route-ledger.ts are unchanged in this hop and still agree.

No must-fix and no should-fix. Nits alone end the round.

Implemented-by: claude/project-thread-32vsaq
Reviewed-by: session_01L9qibzuZJBQY4wUQFJbkfx

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

Seat ACCEPT 6904031398 on #33228 at 01d65d85 (contract review 6902610047 + delta 6903614020, CI green). Over 3000 lines: waiting for GOVERNED_APPROVERS approval; the seat lands it through the queue after that. · 2026-11-16T00:33Z

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 16, 2026
…ithout the framework outbox

Ruling A on the card: the remove door and the optional `userRemoved`
host member stay; durable retry and per-person invitation status are the
host's job. Drops `sys_environment_user_outbox`, its worker, boot and
accepted trigger, every outbox write in add/import/ban/unban/remove,
`deliveryId`, the `invitation` answer fields, the translation bundles and
the census/inventory/registry rows, so main is unchanged outside the door.

A removal that fails after the host took the cancellation sends the
invitation again once through `userAdded` and says whether it worked.
A deactivated pending person who is re-added is not invited: the answer
says `host: { notified: false, reason: 'deactivated' }`.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9
@github-actions github-actions Bot added size/l and removed size/xl labels Nov 16, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#5 · hotlong · session_01Q4EjjPP1zuWBNq3nBXVei9

Contract review (delta, after ruling A)

Served-tier: CONTRACT_REVIEW_TIER (isolated reviewer subagent at the contract tier, run by this seat)
Head-sha: e10b14b317f28c8353db938340cdf1c3fdc27c72
Local-runs: none
Inputs: a read-only review of the net diff against main (merge base 8436f67a2), residue greps on the head tree, and the head's check-runs (39 success, 17 skipped, 1 pending, none failed).
Scope: packages/plugins/plugin-auth/src/{pending-sso-users.ts, environment-user-host.ts, pending-sso-marker.ts, auth-plugin.ts, auth-route-ledger.ts, auth-route-ledger.conformance.test.ts, pending-sso-users.test.ts}, content/docs/permissions/authentication.mdx, the changeset, and the two dogfood admin sweeps.
Security-touching: yes

① Derived judgments: right.

  • The new door's accept set is closed (userId only). Its refusals are 400, 404, 409 (not managed, not pending), the host's own 403/409, and the engine's refusal.
  • userRemoved? and the 'removed' kind are additive, with the userDeactivated + idp_pending fallback.
  • The new outcome reason: 'deactivated' is declared under Clause-②.
  • A deactivated pending re-add still answers 200 alreadyPending, without a host call.
  • The patch changeset touches @objectstack/plugin-auth alone.

② Ruling A conformance: exact. On the head tree there are no hits for sys_environment_user_outbox, environment-user-outbox, opts.retried or the invitation answer fields. deliveryId survives only in an unrelated webhook test. The net diff is 11 files; everything outside them equals main. Docs, the ledger note and the seam header all say that durable retry belongs to the host.

③ Findings

  • S1: "pending only at the write" is a read followed by separate deletes, and the final sys_user delete has no source predicate. A first platform sign-in that commits inside the unit of work leaves a just-signed-in person deleted, answered 200. Fix: put source: 'idp_pending' on the delete; a zero-row delete throws and the child deletes roll back. Add a test that flips source inside the unit of work.
  • S2: on host_failed the removal proceeds. With the outbox gone, nothing can re-ask the cancellation (a second call answers 404), while the ban door fails closed on the same failure. Seat decision: fail closed. Keep the person, answer 503, remove nothing.
  • N1: takeBackPerson's comment and throw text are wrong for the removal caller.
  • N2: isDeactivated should also read the string forms.
  • N3: removeHostUnconfirmed could tell the admin to add the person again to send a new invitation.

Verdict: PASS with should-fix. S1 and S2 are sent back to the dev, with N1–N3, before landing.

…and refuse it when the host is unreachable

Delta review round on the reshaped door:

- The sys_user delete carries `source: idp_pending` (a predicate delete,
  which honours deleteBehavior like the by-id one); a zero-row delete
  throws NoLongerPending, so a first sign-in committing inside the unit of
  work is answered 409 and the child deletes roll back.
- A host that cannot be reached refuses the removal with 503 and nothing
  removed, as it refuses a deactivation: with no framework record nothing
  could ask the host again. The "not confirmed" sentence is gone with the
  path that produced it.
- takeBackPerson's doc and throw text now hold for both callers.
- A banned column read back as '1' or 'true' counts as deactivated.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9
…rs it, and prove the in-unit rollback

The row delete carries `source: 'idp_pending'`, but on an object with
cascading lookups the engine re-deletes by id after the cascade walk, so
a first sign-in committing in that window is not yet refused (#34373, an
engine defect). The docblocks, ledger note, docs and changeset now say
so instead of claiming the window is closed.

The in-unit sign-in test now runs the removal through the plugin's
transactional seam (a snapshot transaction on the memory engine) and
asserts the positions, permission sets and membership survive.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#5 · hotlong · session_01Q4EjjPP1zuWBNq3nBXVei9

ACCEPT · Head-sha: 2e868fa7e24 · 11 files, +733/−34 (767 lines, none generated), all in plugin-auth, its docs and the dogfood sweeps. No governed path, under 3000 lines, so no Tier H. pm:awaiting-merge is removed.

席位核对

  1. Form: ruling A on plugin-auth: the environment-user host seam cannot cancel a pending person's invitation, and has no durable retry or per-row invitation status #33228 (record 6910778242), implemented exactly. The PR keeps the remove door, userRemoved with its fallback, review#1's S1 in-door half, and the inline re-invite. The framework outbox and everything serving it are gone. Retry and status belong to the host.
  2. Reviews, contract tier (isolated reviewer): delta review at e10b14b31 was PASS with S1/S2. The re-review at 1f9b39d26 closed S2 (fail closed: 503, person kept) and N1–N3. S1's residual is an engine defect: a predicate delete on an object with cascading lookups re-deletes by id. It is filed as objectstack#34373, with no workaround here. The final round makes every claim say exactly that, and N4 proves the rollback through the real runAtomically seam (sys_member and the grants survive NoLongerPending). The ablations went red, then were restored.
  3. Gates: plugin-auth suite (279 files, 5,667 passed) and typecheck. The full derived run at 1f9b39d26 was 107 of 108 run, with 1 NOT-MEASURED that CI covers (Lint & Repo Gates). This round touched prose and one test, and the gates that read those files all exit 0. The remaining CI runs on this head.
  4. Accepted deviation: a first sign-in that commits in the engine's find-to-delete window is not yet refused (objectstack#34373). It is stated in the code, docs and PR body.
  5. Out of scope: no explicit admin audit row for a removal (review#1's escalation). Noted for a follow-up card if the maintainer wants it. Where Setup → Users on a managed environment: add-person and CSV-import UI with per-row invitation status (reverses objectui#13330 for adding) #33187 reads the status from stays with Setup → Users on a managed environment: add-person and CSV-import UI with per-row invitation status (reverses objectui#13330 for adding) #33187.
  6. Landing: the seat lands by the maintainer's takeover order 「这个任务你直接接手处理。」: ready, auto-merge, merge queue.

@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 16, 2026
@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 16, 2026 10:39
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 16, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5mjfxPu5HKjUtuveBR

Contract-review-claim: session_01FEkQ5mjfxPu5HKjUtuveBR · head 2e868fa · 2026-11-16T11:32Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5mjfxPu5HKjUtuveBR

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 2e868fa7e24849da3062c3616ba80594c206de7d
Local-runs: none

Inputs: card #33228 (body and all 13 comments, ruling A in 6910778242), the PR body, its 11-file list, the net diff against main (merge base 8436f67a2), the check-runs on this head, and the earlier records on the PR. The PR title still says "retry every environment-user host call from a durable outbox"; the tree has no outbox (ruling A), and this record judges the tree.

① Derived judgments

  • New door POST /api/v1/auth/admin/remove-sso-user. Right as a widening: nothing answered it before. Accept set is closed (userId only; any other key 400). Refusals: 409 off a managed environment, 400, 404, 409 not pending, the host's typed 403/409, 503 when the host cannot be reached, the engine's own refusal for a restricting lookup. Gate and attribution are the add door's (gateAdmin, runAttributedToUser). Ledger row, hygiene pin and both dogfood admin sweeps carry it.
  • EnvironmentUserHost.userRemoved? and EnvironmentUserEventKind 'removed'. Right: additive; a host without the member is asked through userDeactivated with source: 'idp_pending', which the card's ruling makes a cancellation.
  • EnvironmentUserHostOutcome.reason gains 'deactivated'. Right, and declared: an output value on the existing add / import answers. The re-add of a deactivated pending person is still accepted (200 alreadyPending); only the host call is dropped. Not a narrowing of the accept set.
  • No new platform object, spec key, error code or migration: the outbox object, its registry / census / inventory rows and deliveryId are gone from the tree; outside the 11 files the tree equals main.
  • N1 (nit) — pending-sso-users.ts and pending-sso-marker.ts are star-exported from the package index, so runRemoveSsoUser and seven new PENDING_SSO_MESSAGES keys are new public exports the Clause-②: line does not list. Additive; the line's verdict is unchanged.

② Semver level

.changeset/33228-remove-pending-sso-user.md ships patch for @objectstack/plugin-auth alone, with Clause-②: yes (widening) and Metadata-protocol: none, identical to the PR body. Right: plugin-auth is the only released package the diff moves, nothing a metadata author writes changes, and by the AGENTS.md rule a non-protocol widening ships patch. yes (widening) is the right declaration: a new route and new optional contract members, nothing previously accepted is refused. Check Changeset and the PR-body guards are green.

③ Boundary flags

Earlier record 6912496390 (head e10b14b3):

S1 (should-fix) — the host-failure rule for a removal is stated two ways. The code refuses (503). Three places in the head still say the removal proceeds: the EnvironmentUserHost interface docblock in environment-user-host.ts ("reported on the answer for an add, a reactivation or a removal, which it never undoes or blocks") — this ships in the published types and is what a host implementer reads; goesAhead('removed') in the same file, which logs "The removal goes ahead." at the moment the door refuses it; and the environmentUserHost option docblock in auth-plugin.ts. Make all three say what the deactivation arm says: refused, 503, nothing removed.

N2 (nit) — the PR title names a durable outbox the tree does not have. It becomes the commit subject on main; retitle before landing (no head move).

N3 (nit) — a person removed by someone else between the first read and the unit of work answers 409 "not pending" rather than 404.

No must-fix. One should-fix (S1).

Implemented-by: claude/project-thread-32vsaq
Reviewed-by: session_01FEkQ5mjfxPu5HKjUtuveBR

VERDICT: PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:system size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugin-auth: the environment-user host seam cannot cancel a pending person's invitation, and has no durable retry or per-row invitation status

2 participants